<?php
/**
 * Created by PhpStorm.
 * User: HS032
 * Date: 2020/7/15
 * Time: 9:16
 */

namespace pay\modules\backend\controllers;


use pay\modules\backend\models\CommonApp;
use pay\libs\Tools;
use Yii;

/*** 实例控制器
 * Class InstanceController
 * @package backend\controllers
 */
class InstanceController extends BasicController
{
    /*** 实例列表
     * @return false|string
     */
    public function actionList()
    {

        $get = Yii::$app->request->get();
        $page = isset($get['page'])?(int)$get['page']:1;
        $pageSize = isset($get['pageSize'])?(int)$get['pageSize']:10;
        if ($this->userInfo['issuper'] == 1){
            $searchModel = CommonApp::find();
        }else{
            $searchModel = CommonApp::find()->where(['in', 'appid', $this->permissionApps]);
        }

        $total = $searchModel->count();
        $list = $searchModel->offset($pageSize * ($page - 1))->orderBy(['app_id' => SORT_DESC])->asArray()->all();
        return Tools::showRes(0,'success',[
            'list' => $list,
            'page' => $page,
            'size' => $pageSize,
            'total' => $total,
        ]);

    }







}